import React, { useState } from 'react'
import { Navigate } from 'react-router-dom'

export default function Home() {
  const [sum, setSum] = useState(1)
  return (
    <div>
        <h3>Home</h3>
        {/* Navigate只要渲染, 立即跳转 */}
        {sum===4?<Navigate to="/about" />: <h4>当前sum值是: {sum}</h4>}
        <button onClick={()=>setSum(sum+1)}>点我加1</button>
    </div>
  )
}
